package main;

import dao.Hello;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;

public class App {
    public static void main(String[] args) throws IOException {
        InputStream in = Resources.getResourceAsStream("sqlMapperConfig.xml");
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(in);

        SqlSession session = factory.openSession();

        Hello hello = session.getMapper(Hello.class);

        System.out.println(hello.getmapper());
    }

    @Test
    public void test01() throws IOException {
        InputStream in = Resources.getResourceAsStream("sqlMapperConfig.xml");
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(in);

        SqlSession session = factory.openSession();

        Hello hello = session.getMapper(Hello.class);

        System.out.println(hello.getmapper());

        session.commit();
        session.close();
    }
}
